Skip to content

Give freestanding targets a named entry instead of a C main wrapper - #34

Merged
bytetroll merged 1 commit into
masterfrom
anomalous-abi-symbol-surface
Nov 9, 2026
Merged

bytetroll merged 1 commit into
masterfrom
anomalous-abi-symbol-surface

Conversation

@bytetroll

Copy link
Copy Markdown
Contributor

Anomalous ADR 0049 bridges the generated entry with "a separate narrow assembly shim [that] calls the generated C wrapper with zero arguments and implements only its observed ABI-version, context-begin, context-end and failure hooks". The shape was observed because nothing published one: the entry was always the hosted C main(int, char **), so a target with no C runtime had to recognise a wrapper and invent an argument vector for it.

nilassembler --freestanding emits the same entry sequence -- runtime ABI check, context begin, global initialisation, user main, context end -- as __ny_entry(), taking no arguments and defining no main. Nothing about the sequence changes; only the symbol a caller needs to know and the arguments it no longer has to fabricate. The argc/argv derivation is skipped rather than fed zeroes, so a freestanding object carries no argument-vector code at all.

nil.native-symbol-surface now pins both shapes: a hosted object is entered through main, a freestanding one through __ny_entry with no main, and neither widens the import surface beyond the five runtime hooks.

Linux: 573 registered, 0 failed, 3 environment skips.

Anomalous ADR 0049 bridges the generated entry with "a separate narrow
assembly shim [that] calls the generated C wrapper with zero arguments
and implements only its observed ABI-version, context-begin, context-end
and failure hooks". The shape was observed because nothing published
one: the entry was always the hosted C `main(int, char **)`, so a target
with no C runtime had to recognise a wrapper and invent an argument
vector for it.

nilassembler --freestanding emits the same entry sequence -- runtime ABI
check, context begin, global initialisation, user main, context end --
as `__ny_entry()`, taking no arguments and defining no `main`. Nothing
about the sequence changes; only the symbol a caller needs to know and
the arguments it no longer has to fabricate. The argc/argv derivation is
skipped rather than fed zeroes, so a freestanding object carries no
argument-vector code at all.

nil.native-symbol-surface now pins both shapes: a hosted object is
entered through main, a freestanding one through __ny_entry with no
main, and neither widens the import surface beyond the five runtime
hooks.

Linux: 573 registered, 0 failed, 3 environment skips.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@bytetroll
bytetroll merged commit cde211a into master Nov 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant